require.config({
                baseUrl:"../",
               paths:{
               bsl:'bsl',
               }
               });
require(["bsl"],function(bsl){
   alert("good")
        console.log("dbadkafnakfnjkawnfkjawjkfbajkwfbjkwabfjkabwjfbnwanbf");
//require(["./require"], function(require) {
//       var bsl = require.toUrl("./bsl");
    
        document.addEventListener('deviceready', onDeviceready, false);
        function onDeviceready() {
        var  audio=nil;
        var isRecord=false;
        var isPlay=false;

        alert("init Audio")
         var src = "myrecording.wav";
        
        if(window.device.platform.toLowerCase().indexOf("android") > -1) {
        
           src = "myrecording.mp3";
        }
        
        function originalrecord(){
        if(isRecord){
        alert("audio is record")
        return;
        }
        if(isPlay){
        alert("audio is play")
        return;
        
        }
        
        
        audio = new bsl.audio(src,
                          // success callback
                          function() {
                          alert("recordAudio():Audio Success");
                          },
                          
                          // error callback
                          function(err) {
                          alert("recordAudio():Audio Error: "+ err.code);
                          });
        
        // Record audio
          audio.startRecord();
        isRecord=true;

        
        }
        
        function stoprecord(){
        
        audio.stopRecord();
         isRecord=false;
        }
        
        
        
        
        function paly() {
         alert("play");
        if(audio.isStart)
        
        //           audio = new Media("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3",
        
//        audio = new  bsl.audio("http://audio.ibeat.org/content/p1rj1s/p1rj1s_-_rockGuitar.mp3",
                     audio = new bsl.audio(src,
                               // success callback
                               function () {
                               console.log("playAudio():Audio Success");
                               },
                               // error callback
                               function (err) {
                               console.log("playAudio():Audio Error: " + err);
                               }
                               );
        
        // Play audio
        audio.play();
        isPlay=true;
        // Pause after 10 seconds
        //setTimeout(function () {
        //    audio.pause();
        //}, 10000);
        }
        function stoppaly() {
        audio.stop();
        isPlay=false;

        }
        function pause(){
        
        audio.pause()
        }
        function getDuration() {
        audio.getDuration();
        
        }
        function getPosition(){
       audio.getDuration();
        
        }
        
        document.getElementById("record").addEventListener("click", originalrecord, false);
        document.getElementById("stoprecord").addEventListener("click", stoprecord, false);
        document.getElementById("paly").addEventListener("click", paly, false);
        document.getElementById("stoppaly").addEventListener("click", stoppaly, false);
        document.getElementById("pause").addEventListener("click", pause, false);
        document.getElementById("getDuration").addEventListener("click", getDuration, false);
        document.getElementById("getPosition").addEventListener("click", getPosition, false);
        //        document.getElementById("stop").addEventListener("click", stop, false);
        
        }
        })